home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: miker3@ix.netcom.com (Mike Rubenstein)
- Newsgroups: comp.lang.c
- Subject: Re: Q: realloc->free?
- Date: Tue, 16 Jan 1996 03:20:10 GMT
- Organization: Netcom
- Message-ID: <30fb133c.1128448@nntp.ix.netcom.com>
- References: <4daa2e$oh5@axe.netdoor.com> <4df2ud$706@oxy.rust.net>
- NNTP-Posting-Host: ix-dc7-26.ix.netcom.com
- X-NETCOM-Date: Mon Jan 15 7:20:10 PM PST 1996
- X-Newsreader: Forte Agent .99c/16.141
-
- ebennett@rust.net wrote:
-
- |>esargent@netdoor.com (Eric Sargent) wrote:
- |>
- |>
- |>
- |>> Now let's say realloc had to move the data so a != b. Does
- realloc
- |>>free the memory previously pointed to by a or should it be
- explicitly
- |>>freed if realloc returns a new location? I checked the FAQ, but
- there
- |>>was nothing specific about realloc. Thanks for any information.
- |>
- |>realloc() will free the old block. It is perfectly legal to say
- |>
- |> a = realloc(a, newsize);
- |>
- |>No memory loss should occur from this.
-
- What if realloc() fails? This will assign NULL to a and the old value
- will be lost unless it's been stored in some other variable.
-
-
- Michael M Rubenstein
-